package com.thesis.client;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.thesis.object.ListBillDescription;

public class BillDetailStatictisAdapter extends BaseAdapter {
	private final Context context;
	private final ListBillDescription result;
	
	

	public BillDetailStatictisAdapter(Context context,ListBillDescription result) {
		
		this.context = context;
		this.result = result;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView;
		if (convertView == null) {
			rowView = new View(context);
			rowView = inflater.inflate(R.layout.item_bill_detail, parent, false);
		} else {
			rowView = (View) convertView;
		}
		

		TextView tv_food = (TextView) rowView.findViewById(R.id.bd_tv_food);
		TextView tv_cost = (TextView) rowView.findViewById(R.id.bd_tv_unitcost);
		TextView tv_number = (TextView) rowView.findViewById(R.id.bd_tv_number);
		
//		ImageButton btn_bonus = (ImageButton) rowView.findViewById(R.id.bd_ib_bonus);
//		ImageButton btn_minus = (ImageButton) rowView.findViewById(R.id.bd_ib_minus);
		
		tv_food.setText(result.getListBill().get(position).getName());
		tv_cost.setText(""+(result.getListBill().get(position).getCost()/result.getListBill().get(position).getNumber()));
		tv_number.setText(""+result.getListBill().get(position).getNumber());
//		btn_bonus.setImageResource(R.drawable.button_bonus);
//		btn_minus.setImageResource(R.drawable.button_minus);
		return rowView;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return result.getListBill().size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}
}